﻿@model IEnumerable<ShenLanCMS.Models.Ad>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<fieldset>
    <legend>广告管理 @Html.ActionLink("添加", "create") | @Html.ActionLink("类型管理", "index", "adType")</legend>
    <br />
    <table>
        <tr>
            <th>
                标题
            </th>
            <th>
                广告类型
            </th>
            <th>
                开始时间
            </th>
            <th>
                结束时间
            </th>
            <th>
                宽
            </th>
            <th>
                高
            </th>
            <th>
                是否启用
            </th>
            <th>
                操作
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @item.Title
                </td>
                <td>
                    @item.GetAdType().TypeName
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.StartTime)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.EndTime)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Width)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Height)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.IsEnable)
                </td>
                <td>
                    @Html.ActionLink("编辑", "Edit", new { id = item.AdID }) |
                    @Html.ActionLink("详细", "Details", new { id = item.AdID })
                    | <a href="javascript:delAd('@item.AdID')">删除</a>
                </td>
            </tr>
        }
    </table>
</fieldset>
<script type="text/javascript">
    function delAd(obj) {
        if (confirm("确定要删除该广告吗?")) {
            $.post("/ad/delete/" + obj, function (data) {
                alert(data);
                if (data == "删除成功")
                    window.location.reload();
            });
        }
    }
</script>
